<?php
header('Content-Type:application/json');
$code=array("status"=>false,"msg"=>"","data"=>array());
$mysqli = new mysqli('localhost', 'songsong', "123456", 'sids');
$mysqli->query('set names utf8');
find($mysqli,$code);
$mysqli->close();

function find(mysqli $mysqli,array $code)
{
//$class = $_GET['class'];
//$grade = $_GET['grade'];
//$college = $_GET['college'];
//$major = $_GET['major'];
//$class = "04011805";
$grade = "2018";

//$college = "All";
$major ="计算机科学与技术";
//    , grade = '{$grade}', college = '{$college}', major ='{$major}'
$query = "select * from student where major = '{$major}' and grade={$grade}";
if($result=$mysqli->query($query)) 
{
	$code['status']=true;
    $code['msg'] = "find success";
    $code['data']=mysqli_fetch_all($result,MYSQLI_BOTH);
}else
{$code['mag']="not such students";}
$ret = json_encode($code);
echo $ret;
}
?>